<?php

namespace Aitels\Design;


use Illuminate\Support\Facades\Cache;

/**
 * 将数据表定义、数据、以及本次design中的定义缓存起来
 *
 * Class FileCacheStore
 * @package Aitels\Design
 */
class FileCacheStore implements Store
{
    protected $cache;
    protected $prefix;

    public function __construct()
    {
        $this->cache=Cache::store('file');
    }


    public function backup($table, $backUpData)
    {
        $this->cache->forever($this->backupKey($table),$backUpData);


    }

    public function getBackup($table)
    {
        return $this->cache->get($this->backupKey($table));

    }

    public function history($table, $definition)
    {
        $this->cache->forever($this->historyKey($table),$definition);

    }

    public function getHistory($table)
    {
        return $this->cache->get($this->historyKey($table));
    }



    protected function backupKey($table){
        return "DesignBackUp::$table";
    }

    protected function historyKey($table){
        return "DesignHistory::$table";
    }
}